﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Pb;
public class MahjongCoinRoom : MonoBehaviour {

    public GameObject CommonBtn;
    public GameObject LocalTyrantBtn;
    public GameObject ExtremeBtn;

    public List<UILabel> baseScore;
    public List<UILabel> limitScore;
    private void Awake()
    {
        UIEventListener.Get(CommonBtn).onClick = ButtonClick;
        UIEventListener.Get(LocalTyrantBtn).onClick = ButtonClick;
        UIEventListener.Get(ExtremeBtn).onClick = ButtonClick;
    }
    private void Start()
    {
        EginUser user = EginUser.Instance;
        for (int i = 0; i < 3; i++)
        {
            string str = user.ReturnRelCoinForBrief(user.nnRoomList[i].BaseScore);
            //Debug.Log(str);
            baseScore[i].text = "底分：" + str + "金币";
            string str1 = user.ReturnRelCoinForBrief(user.nnRoomList[i].EnterLimit);
            //Debug.Log(str1);
            limitScore[i].text = str1 + "金币准入";
        }
    }
    void ButtonClick(GameObject button)
    {
        if (button.name == "CommonBtn")
        {
            Debug.Log(111);
            SendCoinJoinRoom(1);
        }
        else if (button.name == "LocalTyrantBtn")
        {
            Debug.Log(222);
            SendCoinJoinRoom(2);
        }
        else if (button.name == "ExtremeBtn")
        {
            Debug.Log(333);
            SendCoinJoinRoom(3);
        }
    }

    void SendCoinJoinRoom(int typeId)
    {
        EginUser user = EginUser.Instance;
        if (user.gameType == 1)
        {
            //麻将
            MahjongRandomEnterRoomRequest RR = new Pb.MahjongRandomEnterRoomRequest { TypeId = typeId };
            SocketManager socketManager = SocketManager.Instance;
            socketManager.SendProtobuf1(RR, MsgId.MahjongRandomEnterRoomRequest);
        }
        else if (user.gameType == 2)
        {
            //牛牛
            NnRandomEnterRoomRequest lg = new Pb.NnRandomEnterRoomRequest { TypeId = typeId };
            SocketManager socketManager = SocketManager.Instance;
            socketManager.SendProtobuf1(lg, MsgId.NnRandomEnterRoomRequest);
        }
        else if (user.gameType == 3)
        {

        }
        else if (user.gameType == 4)
        {

        }
    }
}
